from optparse import OptionParser
from model import Node, connection

if __name__ == '__main__':
    usage = "usage: %prog [options] filenames"
    parser = OptionParser()
    parser.add_option("-p", action="store_true", default=False, help="path")
    parser.add_option("-d", action="store_true", default=False, help="date_updated")
    parser.add_option("-c", action="store_true", default=False, help="timestamp")
    parser.add_option("-s", action="store_true", default=False, help="setid")
    parser.add_option("-l", action="store_true", default=False, help="is symlink")
    parser.add_option("-m", action="store_true", default=False, help="md5 hexdigest")
    parser.add_option("-a", action="store_true", default=False, help="all")

    (options, args) = parser.parse_args()

    if len(args) == 0:
        parser.error("need filename or filenames")

    filename = args[0]
    nodes = connection.Node.find({'filename':str(filename)}) 
    print "%s results found" % nodes.count()

    for n in nodes:
        print n.path
